<?php

// $Id: heartbeat.rules_defaults.inc,v 1.1.2.2.2.7 2009/10/24 21:15:14 stalski Exp $

/**
 * @file
 * Rules' pre-configured rules for default drupal core behaviour.
 */

/**
 * Implementation of hook_rules_defaults
 *
 * @return configured rules array
 */
function heartbeat_rules_defaults() {
  $rules = array ();
  $rules['rules'] = array ();
  $rules['rules'] += array (

    'rules_heartbeat_0' => array (
      '#type' => 'rule',
      '#categories' => array (
        0 => 'heartbeat',

      ),
      '#set' => 'event_node_update',
      '#label' => 'Heartbeat - user updates page',
      '#active' => 0,
      '#weight' => '0',
      '#status' => 'default',
      '#conditions' => array (
        0 => array (
          '#type' => 'condition',
          '#settings' => array (
            '#argument map' => array (
              'node' => 'node',

            ),

          ),
          '#name' => 'rules_condition_content_is_published',
          '#info' => array (
            'label' => 'Updated content is published',
            'arguments' => array (
              'node' => array (
                'type' => 'node',
                'label' => 'Content',

              ),

            ),
            'module' => 'Node',

          ),
          '#weight' => 0,

        ),
        1 => array (
          '#weight' => 0,
          '#info' => array (
            'label' => 'Content has type page',
            'label callback' => false,
            'arguments' => array (
              'node' => array (
                'type' => 'node',
                'label' => 'Content',

              ),

            ),
            'module' => 'Node',

          ),
          '#name' => 'rules_condition_content_is_type',
          '#settings' => array (
            'type' => array (
              'page' => 'page',

            ),
            '#argument map' => array (
              'node' => 'node',

            ),

          ),
          '#type' => 'condition',

        ),

      ),
      '#actions' => array (
        0 => array (
          '#type' => 'action',
          '#settings' => array (
            'uid_param' => '[node:author-uid]',
            'uid_target_param' => '0',
            'nid_param' => '[node:nid]',
            'nid_target_param' => '0',
            'message_id_param' => 'heartbeat_edit_node',
            'variables_param' => '@username=|=[user:user-name-url]-|-@node_type=|=[node:type]-|-@node_title=|=[node:title-link]-|-',
            '#eval input' => array (
              'token_rules_input_evaluator' => array (
                'uid_param' => array (
                  0 => 'user',

                ),
                'uid_target_param' => array (
                  0 => 'node',

                ),
                'nid_param' => array (
                  0 => 'node',

                ),
                'nid_target_param' => array (
                  0 => 'node',

                ),
                'variables_param' => array (
                  0 => 'node',
                  1 => 'user',

                ),

              ),

            ),

          ),
          '#name' => 'heartbeat_rules_default_action',
          '#info' => array (
            'label' => 'Logs user activity on node change',
            'label callback' => false,
            'eval input' => array (
              0 => 'uid_param',
              1 => 'uid_target_param',
              2 => 'nid_param',
              3 => 'nid_target_param',
              4 => 'message_id_param',
              5 => 'variables_param',

            ),
            'module' => 'heartbeat',

          ),
          '#weight' => 0,

        ),

      ),
      '#version' => 6003,

    ),

    'rules_heartbeat_1' => array (
      '#type' => 'rule',
      '#categories' => array (
        0 => 'heartbeat',

      ),
      '#set' => 'event_node_insert',
      '#label' => 'Heartbeat - user adds new page content',
      '#active' => 1,
      '#weight' => '10',
      '#status' => 'default',
      '#conditions' => array (
        0 => array (
          '#weight' => 0,
          '#info' => array (
            'label' => 'Created content is published',
            'arguments' => array (
              'node' => array (
                'type' => 'node',
                'label' => 'Inhoud',

              ),

            ),
            'module' => 'Node',

          ),
          '#name' => 'rules_condition_content_is_published',
          '#settings' => array (
            '#argument map' => array (
              'node' => 'node',

            ),

          ),
          '#type' => 'condition',

        ),
        1 => array (
          '#type' => 'condition',
          '#settings' => array (
            'type' => array (
              'page' => 'page',

            ),
            '#argument map' => array (
              'node' => 'node',

            ),

          ),
          '#name' => 'rules_condition_content_is_type',
          '#info' => array (
            'label' => 'Content has type page',
            'label callback' => false,
            'arguments' => array (
              'node' => array (
                'type' => 'node',
                'label' => 'Content',

              ),

            ),
            'module' => 'Node',

          ),
          '#weight' => 0,

        ),

      ),
      '#actions' => array (
        0 => array (
          '#weight' => 0,
          '#info' => array (
            'label' => 'Logs user activity for single users',
            'eval input' => array (
              0 => 'uid_param',
              1 => 'uid_target_param',
              2 => 'nid_param',
              3 => 'nid_target_param',
              4 => 'message_id_param',
              5 => 'variables_param',

            ),
            'module' => 'heartbeat',

          ),
          '#name' => 'heartbeat_rules_default_action',
          '#settings' => array (
            'uid_param' => '[node:author-uid]',
            'uid_target_param' => '0',
            'nid_param' => '[node:nid]',
            'nid_target_param' => '0',
            'message_id_param' => 'heartbeat_add_node',
            'variables_param' => '@username=|=[user:user-name-url]-|-@node_type=|=[node:type-name]-|-@node_title=|=[node:title-link]-|-@types=|=[node:type-name]s-|-',
            '#eval input' => array (
              'token_rules_input_evaluator' => array (
                'uid_param' => array (
                  0 => 'user',

                ),
                'nid_param' => array (
                  0 => 'node',

                ),
                'variables_param' => array (
                  0 => 'node',
                  1 => 'user',

                ),

              ),

            ),

          ),
          '#type' => 'action',

        ),

      ),
      '#version' => 6003,

    ),

    'rules_heartbeat_2' => array (
      '#type' => 'rule',
      '#categories' => array (
        0 => 'heartbeat',

      ),
      '#set' => 'event_comment_insert',
      '#label' => 'Heartbeat - user replies to content (all types)',
      '#active' => 0,
      '#weight' => '3',
      '#status' => 'default',
      '#conditions' => array (),
      '#actions' => array (
        0 => array (
          '#type' => 'action',
          '#weight' => 5,
          '#info' => array (
            'label' => 'Logs relational user activity',
            'eval input' => array (
              0 => 'uid_param',
              1 => 'uid_target_param',
              2 => 'nid_param',
              3 => 'nid_target_param',
              4 => 'message_id_param',
              5 => 'variables_param',

            ),
            'module' => 'Heartbeat activity',

          ),
          '#name' => 'heartbeat_rules_default_action',
          '#settings' => array (
            'uid_param' => '[user:user-id]',
            'uid_target_param' => '[node:author-uid]',
            'nid_param' => '[node:nid]',
            'nid_target_param' => '0',
            'message_id_param' => 'heartbeat_add_comment',
            'variables_param' => '@username=|=[user:user-name-url]  -|-@title=|=[node:title-link]-|-@comment=|=[comment:comment-body-raw]-|-',
            '#eval input' => array (
              'token_rules_input_evaluator' => array (
                'uid_param' => array (
                  0 => 'user',

                ),
                'uid_target_param' => array (
                  0 => 'node',

                ),
                'nid_param' => array (
                  0 => 'node',

                ),
                'variables_param' => array (
                  0 => 'comment',
                  1 => 'node',
                  2 => 'user',

                ),

              ),

            ),

          ),

        ),

      ),
      '#version' => 6003,

    ),

    'rules_heartbeat_3' => array (
      '#type' => 'rule',
      '#categories' => array (
        0 => 'heartbeat',

      ),
      '#set' => 'event_comment_update',
      '#label' => 'Heartbeat - user changes a reply (update comment)',
      '#active' => 0,
      '#weight' => '0',
      '#status' => 'default',
      '#conditions' => array (),
      '#actions' => array (
        0 => array (
          '#weight' => 5,
          '#info' => array (
            'label' => 'Logs relational user activity',
            'eval input' => array (
              0 => 'uid_param',
              1 => 'uid_target_param',
              2 => 'nid_param',
              3 => 'nid_target_param',
              4 => 'message_id_param',
              5 => 'variables_param',

            ),
            'module' => 'Heartbeat activity',

          ),
          '#name' => 'heartbeat_rules_default_action',
          '#settings' => array (
            'uid_param' => '[user:user-id]',
            'uid_target_param' => '[node:author-uid]',
            'nid_param' => '[node:nid]',
            'nid_target_param' => '0',
            'message_id_param' => 'heartbeat_edit_comment',
            'variables_param' => '@username=|=[user:user-name-url]-|-@title=|=[node:title-link]-|-',
            '#eval input' => array (
              'token_rules_input_evaluator' => array (
                'uid_param' => array (
                  0 => 'user',

                ),
                'uid_target_param' => array (
                  0 => 'node',

                ),
                'nid_param' => array (
                  0 => 'node',

                ),
                'variables_param' => array (
                  0 => 'node',
                  1 => 'user',

                ),

              ),

            ),

          ),
          '#type' => 'action',

        ),

      ),
      '#version' => 6003,

    ),

    'rules_heartbeat_4' => array (
      '#type' => 'rule',
      '#categories' => array (
        0 => 'heartbeat',

      ),
      '#set' => 'event_user_update',
      '#label' => 'Heartbeat - After user updates his account',
      '#active' => 1,
      '#weight' => '0',
      '#status' => 'default',
      '#conditions' => array (),
      '#actions' => array (
        0 => array (
          '#weight' => 0,
          '#info' => array (
            'label' => 'Logs default user activity',
            'eval input' => array (
              0 => 'uid_param',
              1 => 'uid_target_param',
              2 => 'nid_param',
              3 => 'nid_target_param',
              4 => 'message_id_param',
              5 => 'variables_param',

            ),
            'module' => 'heartbeat',

          ),
          '#name' => 'heartbeat_rules_default_action',
          '#settings' => array (
            'uid_param' => '[account:uid]',
            'uid_target_param' => '0',
            'nid_param' => '0',
            'nid_target_param' => '0',
            'message_id_param' => 'heartbeat_edit_account',
            'variables_param' => '@username=|=[account:user-name-url]-|-',
            '#eval input' => array (
              'token_rules_input_evaluator' => array (
                'uid_param' => array (
                  0 => 'user',

                ),
                'variables_param' => array (
                  0 => 'account',

                ),

              ),

            ),

          ),
          '#type' => 'action',

        ),

      ),
      '#version' => 6003,

    ),

  );

  // Add an extra message for images, more to show the power of the messages
  if (module_exists('image')) {
    $rules['rules'] += array (

      'heartbeat_rule_add_image' => array (
        '#type' => 'rule',
        '#categories' => array (
          0 => 'heartbeat',

        ),
        '#set' => 'event_node_insert',
        '#label' => 'Heartbeat - user adds new image content',
        '#active' => 1,
        '#weight' => '10',
        '#status' => 'default',
        '#conditions' => array (
          0 => array (
            '#weight' => 0,
            '#info' => array (
              'label' => 'Created content is published',
              'arguments' => array (
                'node' => array (
                  'type' => 'node',
                  'label' => 'Inhoud',

                ),

              ),
              'module' => 'Node',

            ),
            '#name' => 'rules_condition_content_is_published',
            '#settings' => array (
              '#argument map' => array (
                'node' => 'node',

              ),

            ),
            '#type' => 'condition',

          ),
          1 => array (
            '#type' => 'condition',
            '#settings' => array (
              'type' => array (
                'image' => 'image',

              ),
              '#argument map' => array (
                'node' => 'node',

              ),

            ),
            '#name' => 'rules_condition_content_is_type',
            '#info' => array (
              'label' => 'Content has type image',
              'label callback' => false,
              'arguments' => array (
                'node' => array (
                  'type' => 'node',
                  'label' => 'Content',

                ),

              ),
              'module' => 'Node',

            ),
            '#weight' => 0,

          ),

        ),
        '#actions' => array (
          0 => array (
            '#weight' => 0,
            '#info' => array (
              'label' => 'Logs user activity for a user uploading an image',
              'label callback' => false,
              'eval input' => array (
                0 => 'uid_param',
                1 => 'uid_target_param',
                2 => 'nid_param',
                3 => 'nid_target_param',
                4 => 'message_id_param',
                5 => 'variables_param',

              ),
              'module' => 'heartbeat',

            ),
            '#name' => 'heartbeat_rules_default_action',
            '#settings' => array (
              'uid_param' => '[user:user-id]',
              'uid_target_param' => '0',
              'nid_param' => '[node:nid]',
              'nid_target_param' => '0',
              'message_id_param' => 'heartbeat_add_image',
              'variables_param' => '@username=|=[user:user-name-url]-|-@title=|=[node:title-link]-|-@image=|=[node:node-image-thumbnail-link]-|-',
              '#eval input' => array (
                'token_rules_input_evaluator' => array (
                  'uid_param' => array (
                    0 => 'user',

                  ),
                  'nid_param' => array (
                    0 => 'node',

                  ),
                  'nid_target_param' => array (
                    0 => 'node',

                  ),
                  'variables_param' => array (
                    0 => 'node',
                    1 => 'user',

                  ),

                ),

              ),

            ),
            '#type' => 'action',

          ),

        ),
        '#version' => 6003,

      ),

    );
  }

  return $rules;

}